<?php
require('inc/header.php');

// AudioShout 0.1.0 Alpha

// Displays information about a specified file.

if (empty($_GET['id']))
	{
		echo '<h1>Oops!</h1>We could not find the file you requested. Please make sure its ID is correct and then try again.';
	}
	else
	{
	$ID = intval($_GET['id']);
fileinfo($ID);
$filename = fileinfo($ID)[0];
$filedate = fileinfo($ID)[2];
$filehash = fileinfo($ID)[1];
$filesize = fileinfo($ID)[3];
$title = fileinfo($ID)[4];

	if ($filename)
	{
		echo '<audio id="audio" preload="metadata" src="http://'.$domain.'/p/'.$ID.'"></audio>';
echo $date;
		echo '<h1>File Details</h1>
		Use the links and buttons below to listen to, download, or share this audio file with your friends.
		<table summary="Displays information about this file">
			<tr><td>Title:</td><td>'.$title.'</td></tr>
			<tr><td>File name:</td><td>'.$filename.'</td></tr>
			<tr><td>File ID:</td><td>'.$ID.'</td></tr>
			<tr><td>Created on:</td><td>'.date('l, F jS, Y, H:i:s',strtotime($filedate)).' UTC</td></tr>
			<tr><td>File hash:</td><td>'.$filehash.'</td></tr>
			<tr><td>File size:</td><td>'.round($filesize/1024/1024,2).' MB</td></tr>
		</table>';
		echo '<a href="javascript:play_audio()">Listen online (experimental)</a> (<a href="javascript:pause_audio()">pause</a>)';
		echo '<a href="http://'.$domain.'/dl/'.$ID.'">Download now</a>';

		// Twitter and Facebook links
		echo '<div id="fb-root"></div>
	<script>(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, '."'script', 'facebook-jssdk'));</script>";
		echo '<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://'.$domain.'/'.$ID.'" data-text="I\'m listening to a great audio clip right now on #'.$sitename.'! Check it out at " data-size="large">Tweet</a>
		<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
		<div class="fb-like" data-href="http://'.$domain.'/'.$ID.'" data-send="true" data-width="300" data-show-faces="false" data-action="recommend" data-colorscheme="dark"></div>';
		flush();
		file_get_contents("http://$SQLMaster.$domain/api/report.php?a=v&id=$ID");
	}
else
{
  echo "<h1>Oops!</h1>
	We're sorry, but the file you are looking for does not exist. Please try again. (404)";
  }
}
require('inc/footer.php');
?>

